package models

import (
	"time"

	"gorm.io/gorm"
)

const TableNameUser = "users"

const (
	RoleAdmin = "admin"
	RoleUser  = "user"
)

// User mapped from table <users>
type User struct {
	ID           int32          `gorm:"column:id;primaryKey" json:"id"`
	Username     string         `gorm:"column:username;not null" json:"username"`
	PasswordHash string         `gorm:"column:password_hash;not null" json:"password_hash"`
	Role         string         `gorm:"column:role;not null;default:'user'" json:"role"`
	CreatedAt    time.Time      `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt    time.Time      `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
	DeletedAt    gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at"`
}

// TableName User's table name
func (*User) TableName() string {
	return TableNameUser
}
